<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp"%>
<%@ include file="/commons/tag.jsp"%>
<%@ include file="/commons/js/basejs.jsp"%>
<%@ include file="/commons/js/extjs.jsp"%>
<%@ include file="/commons/css/basecss.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<body id="mainBody" class="easyui-layout">
<input class="easyui-textbox" style="width:100px;">
<table id="treeGrid" ></table>
<div id="win" class="easyui-window" title="My Window" style="width:600px;height:400px"   
        data-options="iconCls:'icon-save',modal:true,closed:true">   
   <form id="update" method="post">   
	    <div>   
	        <label>商品名称:</label>   
	        <input class="easyui-validatebox" type="text" id="orderNo" name="orderNo"/>   
	    </div>   
	    <div>   
	        <label>商品类别  :</label>   
	        <input class="easyui-validatebox" type="text" name="facName" id="facName" disabled="disabled"/>   
	    </div>  
	    <div>   
	        <label>展示位置:</label>   
	        <label><input name="re" type="checkbox" value="" />最热商品 </label> 
			<label><input name="xin" type="checkbox" value="" />是否新品 </label> 
			<label><input name="gao" type="checkbox" value="" />高性价比商品 </label>    
	    </div>   
	    <div>   
	        <label>订单金额  :</label>   
	        <input class="easyui-validatebox" type="text" name="amountTotal" id="amountTotal"/>   
	    </div>  
	    <div>   
	        <label>订单状态  :</label>   
	        <input class="easyui-validatebox" type="text" name="orderStatus" id="orderStatus"/>   
	    </div> 
	    <div>   
	        <label>支付状态  :</label>   
	        <input class="easyui-validatebox" type="text" name="payStatus" id="payStatus"/>   
	    </div> 
	    <div>   
	        <label>商品详情  :</label> <br>  
	        <table id="table2"></table>
	    </div> 
	    <div>     
	        <button id="tijiao">提交</button>
	    </div> 
	</form>  
</div>   
	<div class="easyui-layout" data-options="fit:true,border:false" style="overflow: hidden;width:100%">
        <div data-options="region:'center',border:false"  >
            
        </div>
    </div>
    <div data-options="region:'center'" style="overflow-x: hidden">
		<div id="tabs" class="easyui-tabs" data-options="fit:true,border:false">
			<div id="systemMenu" title="商品列表">
			<table id="table1"></table>
				<div id="datagrid_toolbar">
			 	 请选择厂商 :
				<input id="fac" class="easyui-combobox" name="fac" 
		  		  data-options="valueField:'label',textField:'value',url:'${base}/SystemProduct/findAllFactory'"/>  
				关键字:
				<input id="keyword" class="text" name="keyword" placeholder="包括商品名字/编码"/>  
			        <a onclick="doSearch()" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'">查看</a>
			        <div class="td_right">
						<a onclick=";" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">添加</a>
						<a onclick="findDetail()" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">编辑</a>
				       	<a onclick="deletes()" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-del'">删除</a>
			       	</div>
				</div>
			</div>
		</div>
	</div>
</div>
	
	<script type="text/javascript">
	$(function(){
		$('#table1').datagrid({
			url: '${base}/SystemProduct/findBySenior',
			fit: true,
			border: false,
			pagination: true,// 分页
			pagePosition: 'bottom',
			idField: 'id',
			pageSize: 20,
			pageList: [10,20,30,50],
			checkOnSelect: true,
			selectOnCheck: true,
			singleSelect: false,
			nowrap: true, 
			rownumbers: true, //显示行号
			showfooter: true, //显示行尾
			pageNumber: 1,
			fitColumns:true,
			sortName: 'updateTime',	//按字段排序
			sortOrder: 'desc',		//倒序
			toolbar:'#datagrid_toolbar',
			columns : [[
			 {field : 'id', title :'id', width : 50, hidden: true},
			 {field : 'productName', title:'商品名称', width : '13%', align : 'center'},
			 {field : 'categoryName', title:'分类名称', width : '13%', align : 'center'},
			 {field : 'productSpec', title:'商品规格', width : '13%', align : 'center'},
			 {field : 'productNumber', title:'商品编号', width : '11%', align : 'center'},
			 {field : 'productPrice', title:'商品价格', width : '11%', align : 'center',sortable:true},
			 {field : 'unitName', title:'单位名称', width : '11%', align : 'center'},
			 {field : 'isDefault', title:'是否默认', width : '11%', align : 'center',sortable:true,
				 	formatter:function(value,row,index){
				 		 if (0 == value) return '否';
						 else if (1 == value) return '是';
						 else return '';
				 	}},
			 {field : 'isDelete', title:'是否删除', width : '11%', align : 'center',sortable:true,
					formatter:function(value,row,index){
					 	if (0 == value) return '已删除';
						else if (1 == value) return '未删除';
						else return '';
					}}/* ,
			 {field :'action', title:'操作', width:80, align:'center',
					formatter:function(value,row,index){
						var e = '<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:\'icon-edit\',plain:true" onclick="hiddangerinfo_table_editrow(this)">编辑</a> ';
						var d = '<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:\'icon-del\',plain:true" onclick="hiddangerinfo_table_deleterow(this)">删除</a>';
						return e+d;
					}
				} */]],
	   });
	});
		function deletes(){
			/*  swal({
			    title: "确定删除吗？",
			    text: "你将无法恢复该虚拟文件！",
			    type: "warning",
			    showCancelButton: true,
			    confirmButtonColor: "#DD6B55",
			    confirmButtonText: "确定删除！",
			    closeOnConfirm: false
			},
			function(){
			    swal("删除！",
			    "你的虚拟文件已经被删除。",
			    "success");
			});  */
			 var row = $('#table1').datagrid('getSelections');
			var ids = "";
				for(var i in row){
					ids += ","+row[i].id;
				}
				console.info(ids);
			   $.ajax({  
                type : "POST",  
                url : "${base}/SystemProduct/deleteProdect",
                data : {
                	ids: ids
                },
                success : function(result) {
                	if(result == 0){
                    	swal("", "删除失败,包含默认商品","error");
                	} else {
                		/* swal("", "删除成功","success"); */
                	}
                	$('#table1').datagrid('load',{
						condition: $('#keyword').val(),
						facId: $('#fac').combobox('getValue')
					});
                }  
            });      
		}
		function doSearch(){
			$('#table1').datagrid('load',{
				keyword: $('#keyword').val(),
				facId: $('#fac').combobox('getValue')
			});
		}
		
		function findDetail(){
			 var row = $('#table1').datagrid('getSelections');
			 if(row.length != 1){
				 swal("", "操作失败,请选择一个商品","error");
			 }
			  $.ajax({  
	                type : "POST",  
	                url : "${base}/SystemOrder/orderDetail",
	                data : {
	                	id: 613,
	                	facId:65
	                },
	                success : function(result) {
	                	var data =JSON.parse(result);
	                	console.info(data);
	                	$('#orderNo').val(data.orderNo);
	                	$('#facName').val(row[0].facName);
	                	$('#ageName').val(data.ageName);
	                	$('#amountTotal').val(data.amountTotal);
	                	if (0 == data.orderStatus) {$('#orderStatus').val('待审核')}
						 else if (1 == data.orderStatus) { $('#orderStatus').val('待财务审核')}
						 else if (2 == data.orderStatus) { $('#orderStatus').val('待发货')}
						 else if (3 == data.orderStatus) { $('#orderStatus').val('部分发货')}
						 else if (4 == data.orderStatus) { $('#orderStatus').val('待收货')}
						 else if (5 == data.orderStatus) { $('#orderStatus').val('确认收货')}
						 else if (6 == data.orderStatus) { $('#orderStatus').val('订单完成')}
						 else if (9 == data.orderStatus) { $('#orderStatus').val('暂存')}
						 else { $('#orderStatus').val()};
						 if (0 == data.payStatus) {$('#payStatus').val('未付款')}
						 else if (1 == data.payStatus) { $('#payStatus').val('部分付款')}
						 else if (2 == data.payStatus) { $('#payStatus').val('已付款')}
						 else if (3 == data.payStatus) { $('#payStatus').val('代确认')}
						 else { $('#payStatus').val()};
	                }  
	            });      
			$('#win').window('open');  // open a window    
		}
	</script>
</body>
</html>